//
//  RZSocketRocketManager.h
//  Water
//
//  Created by reyzhang on 2021/7/13.
//  对SocketRocket 库的封装 reyzhang

#import <Foundation/Foundation.h>
#import <SocketRocket/SocketRocket.h>
#import "RZMessage.h"

NS_ASSUME_NONNULL_BEGIN

extern NSString * const RZNotification_SocketRocketDidOpen;
extern NSString * const RZNotification_SocketRocketDidOpenFailure;
extern NSString * const RZNotification_SocketRocketDidClose;
extern NSString * const RZNotification_SocketRocketDidReceive;


//接收到的Socket消息
typedef NSString * RZSocketResponseType NS_STRING_ENUM;

//用户在其他地方登录
FOUNDATION_EXPORT RZSocketResponseType const RZSocketResponseTypeOtherLogin;
//服务器断开连接
FOUNDATION_EXPORT RZSocketResponseType const RZSocketResponseTypeServerDisconnect;



@interface RZSocketRocketManager : NSObject

+ (instancetype)shareInstance;

/** 获取连接状态 */
@property (nonatomic, assign, readonly) SRReadyState socketReadyState;
/**是否需要重连 默认YES*/
@property (nonatomic, assign) BOOL needReConnect;

/** 开启连接 */
- (void)openWithURLString:(NSString *)urlString token:(NSString *)token;

- (void)openWithURLRequest:(NSURLRequest *)request;

/** 关闭连接 */
- (void)close;



/** 发送数据 */
- (void)sendData:(id)data;

/** 发送消息 */
- (void)sendMesage:(RZMessage *)message;
@end


NS_ASSUME_NONNULL_END
